*Ura & Wohlfarth PSRM*
*Replication Maker*
*June 2020*


* working directory 


insheet using "jurisdictionStrippingLaws.csv"

drop date

gen loggedPctStrip = ln(1+pctstrippl)

*tsset year
*gen pctstrippl_Lag1 = l.pctstrippl
*gen loggedPctStrip_Lag1 = l.loggedPctStrip

sort year
merge year using "gssConfidence.dta"
keep if year > 1971 & year < 2015
drop _merge
drop ratiofed confed hatefed ratiojudge ratiolegis

gen courtCongRelativeConf = (conjudge - conlegis)
gen courtNetConf = (conjudge - hatejudge)
gen congNetConf = (conlegis - hatelegis)

sort year
merge year using "baileyIdeology.dta"
keep if year > 1971 & year < 2015
drop _merge

gen baileyDist_Midpoint = abs(supremecourtmedian - ((senatemedian + housemedian)/2))
gen baileyDist_President = abs(supremecourtmedian - president)
gen baileyDist_midCongPres = abs(president - ((senatemedian + housemedian)/2))

gen unifiedGov = 0
replace unifiedGov = 1 if year == 1977
replace unifiedGov = 1 if year == 1978
replace unifiedGov = 1 if year == 1979
replace unifiedGov = 1 if year == 1980
replace unifiedGov = 1 if year == 1993
replace unifiedGov = 1 if year == 1994
replace unifiedGov = 1 if year == 2003
replace unifiedGov = 1 if year == 2004
replace unifiedGov = 1 if year == 2005
replace unifiedGov = 1 if year == 2006
replace unifiedGov = 1 if year == 2009
replace unifiedGov = 1 if year == 2010
replace unifiedGov = 1 if year == 2017
replace unifiedGov = 1 if year == 2018

gen unifiedCongress = 1
replace unifiedCongress = 0 if year == 1981
replace unifiedCongress = 0 if year == 1982
replace unifiedCongress = 0 if year == 1983
replace unifiedCongress = 0 if year == 1984
replace unifiedCongress = 0 if year == 1985
replace unifiedCongress = 0 if year == 1986
replace unifiedCongress = 0 if year == 2001
replace unifiedCongress = 0 if year == 2002
replace unifiedCongress = 0 if year == 2011
replace unifiedCongress = 0 if year == 2012
replace unifiedCongress = 0 if year == 2013
replace unifiedCongress = 0 if year == 2014

sort year
merge year using "workload.dta"

*tsset year
gen workloadThousands = chutkowWorkload/1000
*gen workloadThousandsDiff = d.workloadThousands
gen workloadThousands_allCivil = usCivilTotal/1000
*gen workloadThousandsDiff_allCivil = d.workloadThousands_allCivil

drop _merge
sort year 
merge year using "totalJudges.dta"

*Adjusted Workload -- Using Civil Cases w/ U.S. as Defendant
gen workloadPerJudge_All = workloadThousands/totaljudges_allart3
gen workloadPerJudge_District = workloadThousands/totaljudges_district

*Adjusted Workload -- Using ALL U.S. Civil Cases
gen workloadPerJudgeAll_All = workloadThousands_allCivil/totaljudges_allart3
gen workloadPerJudgeAll_District = workloadThousands_allCivil/totaljudges_district
*tsset year
*gen workloadPerJudgeAllDiff_District = d.workloadPerJudgeAll_District

keep if year > 1971 & year < 2015
drop _merge
drop authorizedjudges_district
drop usCivilDefendant

gen totalplHundreds = totalpl/100


sort year
merge year using "markZilisAggregateCurbing.dta"
keep if year > 1971 & year < 2015
drop _merge
rename bills curbingBills
rename logbills logCurbingBills


sort year
merge year using "jcsMedians.dta"
rename senate senate_JCS
rename house house_JCS 
rename SCmedian SCmedian_JCS
egen congressMedian_JCS = rowmedian(senate_JCS house_JCS)
egen circuitsMedian_JCS = rowmedian(First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh DC)
gen congCourtDist_JCS = abs(SCmedian_JCS - congressMedian_JCS)
gen congCircuitsDist_JCS = abs(congressMedian_JCS - circuitsMedian_JCS)
gen congDCDist_JCS = abs(congressMedian_JCS - DC)
*tsset year
*gen congDCDistDiff_JCS = d.congDCDist_JCS
keep if year > 1971 & year < 2015
drop congress term _merge
drop DCsd Eleventhsd Tenthsd Ninthsd Eighthsd Seventhsd Sixthsd Fifthsd Fourthsd Thirdsd Secondsd Firstsd 


label variable year "Calendar Year"
label variable jurstriptotal "Total # of Jurisdiction Stripping Laws"
label variable totalpl "Total # of Public Laws Each Year"
label variable pctstrippl "Percentage of Public Laws w/ Jurisdiction Stripping"
*label variable pctstrippl_Lag1 "First Lag of pctstrippl"
label variable loggedPctStrip "Natural Log of pctstrippl"
*label variable loggedPctStrip_Lag1 "First Lag of loggedPctStrip"
label variable conlegis "Proportion w/ Confidence in Congress"
label variable hatelegis "Proportion w/ No Confidence in Congress"
label variable conjudge "Proportion w/ Confidence in the Supreme Court"
label variable hatejudge "Proportion w/ No Confidence in the Supreme Court"
label variable courtCongRelativeConf "Relative Confidence (Court minus Congress)"
label variable courtNetConf "Supreme Court Net Confidence (confidence minus no confidence)"
label variable congNetConf "Congress Net Confidence (confidence minus no confidence)"
label variable supremecourtmedian "Bailey Ideology -- Supreme Court Median"
label variable president "Bailey Ideology -- President"
label variable senatemedian "Bailey Ideology -- U.S. Senate Median"
label variable housemedian "Bailey Ideology -- U.S. House Median"
label variable baileyDist_Midpoint "Ideological Distance -- Supreme Court & Congress Median (Bailey)"
label variable baileyDist_President "Ideological Distance -- Supreme Court & President (Bailey)"
label variable baileyDist_midCongPres "Ideological Distance -- President & Congress Median (Bailey)"
label variable unifiedGov "1 = Unfied Government (President & Congress); 0 = Divided"
label variable unifiedCongress "1 = Unfied Congress; 0 = Divided"
label variable chutkowWorkload "Total # of Civil Cases Filed Against U.S. in District Courts (preceding year)"
label variable usCivilPlaintiff "Total # of Civil Cases Filed By U.S. in District Courts (preceding year)"
label variable usCivilTotal "Total # of Civil Cases Involving U.S. in District Courts (preceding year)"
label variable workloadThousands "Thousands of Civil Cases Filed Against U.S. in District Courts (preceding year)"
*label variable workloadThousandsDiff "First Difference of workloadThousands"
label variable workloadThousands_allCivil "Thousands of Civil Cases Involving U.S. in District Courts (preceding year)"
*label variable workloadThousandsDiff_allCivil "First Difference of workloadThousands_allCivil"
label variable totaljudges_allart3 "Total # of Article III Judges"
label variable totaljudges_district "Total # of District Court Judges"
label variable workloadPerJudge_All "Thousands of U.S. Defendant Civil Cases Per Article III Judge (workloadThousands/totaljudges_allart3)"
label variable workloadPerJudge_District "Thousands of U.S. Defendant Civil Cases Per District Judge (workloadThousands/totaljudges_district)"
label variable workloadPerJudgeAll_All "Thousands of All U.S. Civil Cases Per Article III Judge (workloadThousands_allCivil/totaljudges_allart3)"
label variable workloadPerJudgeAll_District "Thousands of All U.S. Civil Cases Per District Judge (workloadThousands_allCivil/totaljudges_district)"
*label variable workloadPerJudgeAllDiff_District "First Difference of workloadPerJudgeAll_District"
label variable totalplHundreds "Hundreds of Public Laws Each Year"
label variable curbingBills "Total # of Court Curbing Bills Each Year (Mark & Zilis)"
label variable logCurbingBills "Natural Log of curbingBills"
label variable senate_JCS "JCS Ideology -- U.S. Senate Median"
label variable house_JCS "ICS Ideology -- U.S. House Median"
label variable SCmedian_JCS "JCS Ideology -- Supreme Court Median"
label variable First "1st Circuit Median Judge (JCS)"
label variable Second "2nd Circuit Median Judge (JCS)"
label variable Third "3rd Circuit Median Judge (JCS)"
label variable Fourth "4th Circuit Median Judge (JCS)"
label variable Fifth "5th Circuit Median Judge (JCS)"
label variable Sixth "6th Circuit Median Judge (JCS)"
label variable Seventh "7th Circuit Median Judge (JCS)"
label variable Eighth "8th Circuit Median Judge (JCS)"
label variable Ninth "9th Circuit Median Judge (JCS)"
label variable Tenth "10th Circuit Median Judge (JCS)"
label variable Eleventh "11th Circuit Median Judge (JCS)"
label variable DC "D.C. Circuit Median Judge (JCS)"
label variable congressMedian_JCS "JCS Median Between U.S. House & Senate"
label variable circuitsMedian_JCS "JCS Median of Circuit Court Medians"
label variable congCourtDist_JCS "JCS Ideological Distance -- Supreme Court & Congress Median"
label variable congCircuitsDist_JCS "JCS Ideological Distance -- Median Circuit Court & Congress Median"
label variable congDCDist_JCS "JCS Ideological Distance -- D.C. Circuit & Congress Median"
*label variable congDCDistDiff_JCS "First Difference of congDCDist_JCS"
            
sort year
tsset year

save "uraWohlfarthPSRM.dta", replace
outsheet using "uraWohlfarthPSRM.csv", comma replace 

